package com.esri.core.map;

import com.esri.core.internal.util.d;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class ServerError {
    private long a;
    private String b;
    private Throwable c;

    public ServerError(Exception exc) {
        this.b = "";
        this.b = exc.getMessage();
        this.c = exc;
    }

    private ServerError() {
        this.b = "";
    }

    public ServerError(String str) {
        this(new Exception(str));
    }

    public long getCode() {
        return this.a;
    }

    public String getDescription() {
        return this.b;
    }

    public static ServerError fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            ServerError serverError = new ServerError();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                if (currentName.equals("code")) {
                    serverError.a = jsonParser.getLongValue();
                } else if (currentName.equals("description") || currentName.equals("message")) {
                    if (!serverError.b.isEmpty()) {
                        serverError.b += ", ";
                    }
                    serverError.b += jsonParser.getText();
                } else if (currentName.equals("details")) {
                    if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) {
                        while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                            if (!serverError.b.isEmpty()) {
                                serverError.b += ", ";
                            }
                            serverError.b += jsonParser.getText();
                        }
                    }
                } else {
                    jsonParser.skipChildren();
                }
            }
            return serverError;
        }
        return null;
    }

    public Throwable getThrowable() {
        Throwable th = this.c;
        return th == null ? new Throwable(this.b) : th;
    }
}
